package com.springboot.mall.controller;

import com.github.pagehelper.PageInfo;
import com.springboot.mall.common.ApiRestResponse;
import com.springboot.mall.model.entity.Product;
import com.springboot.mall.model.request.ProductListRequset;
import com.springboot.mall.service.ProductService;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/*
 *
 *
 *@data 2022-05-13
 */
@Controller
public class ProductController {
    @Autowired
    private ProductService productService;

    @PostMapping("/product/detail")
    @ResponseBody
    public ApiRestResponse detail(Integer id){
        Product detail = productService.detail(id);
        return ApiRestResponse.success(detail);
    }

    @PostMapping("/product/list")
    @ResponseBody
    public ApiRestResponse adminProductList(ProductListRequset productListRequset){
        PageInfo pageInfo = productService.list(productListRequset);
        return ApiRestResponse.success(pageInfo);
    }
}
